package com.smag.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smag.common.core.domain.AjaxResult;
import com.smag.system.domain.FarmOrderAddress;
import com.smag.system.service.FarmOrderAddressService;
import com.smag.system.mapper.FarmOrderAddressMapper;
import org.springframework.stereotype.Service;

/**
* @author hzqhzq
* @description 针对表【farm_order_address】的数据库操作Service实现
* @createDate 2023-04-25 21:21:44
*/
@Service
public class FarmOrderAddressServiceImpl extends ServiceImpl<FarmOrderAddressMapper, FarmOrderAddress>
    implements FarmOrderAddressService{

    @Override
    public AjaxResult getUserAddress(Long userId) {
        LambdaQueryWrapper<FarmOrderAddress> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FarmOrderAddress::getUserId,userId);
        return AjaxResult.success(list(queryWrapper));
    }

    @Override
    public AjaxResult addUserAddress(FarmOrderAddress farmOrderAddress) {
        if (save(farmOrderAddress)) {
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
}




